package com.ex.shapejudge;

import com.ex.question.base.ShapeJudgeQuestion;

public class LineJudgeQuestion extends ShapeJudgeQuestion {

	int mPointX1, mPointY1;
	int mPointX2, mPointY2;
	int mPointX3, mPointY3;

	public LineJudgeQuestion() {
		createQuestion();

	}

	public LineJudgeQuestion(int x1, int x2, int x3, int y1, int y2, int y3) {
		createQuestion(x1, x2, x3, y1, y2, y3);
	}

	public boolean Judge() {
		double a = (mPointY1 - mPointY2) / (mPointX1 - (double) mPointX1);
		double b = mPointY1 - a * mPointX1;

		double tempY = a * mPointX3 + b;
		if (tempY == (double) mPointY3)
			return true;
		else
			return false;
	}

	public void createQuestion() {
		createQuestion(mRand.getRandom10(), mRand.getRandom10(), mRand.getRandom10(), mRand.getRandom10(),
				mRand.getRandom10(), mRand.getRandom10());
	}

	public void createQuestion(int x1, int x2, int x3, int y1, int y2, int y3) {
		mPointX1 = x1;
		mPointY1 = y1;
		mPointX2 = x2;
		mPointY2 = y2;
		mPointX3 = x3;
		mPointY3 = y3;
		this.mRightAnswer = Judge();
	}
}
